Font Dialog
Volume Number: 4
Issue Number: 7
Column Tag: Assembly Language Lab
Font Dialog Box Using List Manager 
By Ray A. Cameron, Brunswick, Victoria, Australia
Ray. A. Cameron is an Electrical Engineer from Brunswick, Victoria in Australia,
employed by Telecom, the Australian Telecommunication Commission. He is currently
involved in the introduction of optical fibre into the Customer Access Network. This is
his first article for MacTutor.
MacTutor Down Under
Before I start writing about my routines l’d like to say how fantastic MacTutor is
for the service that it is providing to Mac programmers in disseminating programming
ideas and techniques. It doesn’t matter which language we program in, it is possible to
gain information from every article published in MacTutor.
Something that I know would be beneficial to all readers of MacTutor is if the
writers of articles include in their description not only how the program works (as
published) but what problems they have encountered along the way or techniques thay
have employed and why. Also any idiosyncrasies in the system software that don’t
appear to be fully explained in Inside Macintosh.
What This Program Does
The FontDialog routine displays a Modal Dialog box for the user to select a font
name, size and style. The routine is designed to be incorporated into a program, as I
have done with the “Window” example (distributed with the old MDS software and
included here), which is on this month’s source disk. There are two routines that I
have written, the first routine (SetupFontMap) creates a record of all the ‘FONT’
resources available to the user in the system file. It doesn’t look for ‘FOND’ or ‘NFNT’
resources or fonts attached to documents. The next routine (FontDialog) creates a
Modal Dialog box (Fig 1) so that the user can choose a font name, size and style. The
font name and size lists are created with the List Manager from data stored in the
FontMap record. The routine also includes a UserFilter with the Modal Dialog to handle
events.
Some of the procedures and functions used in the FontDialog routine take up a
number of lines and are used often so l’ve converted them into Macros to save space. I
won’t describe the Macro file as it should be self explanatory.
Fig. 1 Our Font Dialog Box selects text, size & style
The Dialog box presented in this example is similar to the one in Microsoft Word.
Now that we can all use nested menus to select font, size and style, you might want to be
old fashioned and go back to a text dialog box instead! You can select a font name by
either clicking on a font name or by typing a character to select the first name starting
with that character (or the first name to follow in alphabetical order). As you
continue to type additional characters (up to 31) any file that matches the characters
you type is found and selected. If you pause while typing, the next character is
considered to be a new request, rather than a continuation of your first request. The
Delay Until Repeat setting which you set in the (Control Panel) determines how long
you can pause before additional characters are considered to be a new request. Hence
our dialog box is fairly intelligent in that it includes a sort and search routine and uses
the list manager, useful techniques for a variety of dialog functions.
The Font Size Selection Window displays the sizes that are currently available on
the system (for the selected font name). If no font name is selected then the Font Size